package com.hrpmar.controller;

import com.hrpmar.service.WorkerService;
import com.hrpmar.utils.Constants;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * Created by dell on 2017/12/2.
 */
@RestController
@RequestMapping("/user")
public class UserInfoRestController {

    String msg = null;

    @Resource
    private WorkerService workerService;

    @PostMapping("/updatePwd")
    public String updatePwd(Integer woId, String newlandPwd, HttpSession session){
        try{
            if (workerService.updatePwd(woId,newlandPwd)>0){
                session.removeAttribute(Constants.LOGIN_USER);
                msg="";
            }
        }catch (RuntimeException e){
            msg="修改密码失败！";
        }
        return msg;
    }

}
